#include "DefaultParameterContainer.h"

DefaultParameterContainer *DefaultParameterContainer::instance = NULL;

Color* DefaultParameterContainer::figureColor=NULL;

Color* DefaultParameterContainer::screenColor=NULL;

Color* DefaultParameterContainer::lineColor=NULL;

Color* DefaultParameterContainer::defaultFigureColor = NULL;

Color* DefaultParameterContainer::defaultLineColor = NULL;

Color* DefaultParameterContainer::defaultScreenColor = NULL;

DefaultParameterContainer* DefaultParameterContainer::getInstance(){
	if(DefaultParameterContainer::instance==NULL)
		DefaultParameterContainer::instance = new DefaultParameterContainer();
	return DefaultParameterContainer::instance;
}

DefaultParameterContainer::~DefaultParameterContainer(){}

void DefaultParameterContainer::destroy(){

	if(DefaultParameterContainer::defaultFigureColor!=NULL)
		delete DefaultParameterContainer::defaultFigureColor;
	
	if(DefaultParameterContainer::defaultLineColor !=NULL)
		delete DefaultParameterContainer::defaultLineColor;
	
	if(DefaultParameterContainer::defaultScreenColor !=NULL)
		delete DefaultParameterContainer::defaultScreenColor;
	
	if(DefaultParameterContainer::figureColor!=NULL)
		delete DefaultParameterContainer::figureColor;
	
	if(DefaultParameterContainer::lineColor !=NULL)
		delete DefaultParameterContainer::lineColor;
	
	if(DefaultParameterContainer::screenColor !=NULL)
		delete DefaultParameterContainer::screenColor;

	if(DefaultParameterContainer::instance!=NULL)
		delete DefaultParameterContainer::instance;
	DefaultParameterContainer::instance = NULL;
}

DefaultParameterContainer::DefaultParameterContainer(){
	this->screenHeight=0;
	this->screenWidth=0;
	this->defaultScreenHeight = 600;
	this->defaultScreenWidth = 800;
	this->defaultFigureColor = new Color(255,255,255);
	this->defaultLineColor = new Color(255,255,255);
	this->defaultScreenColor = new Color(0,0,0);

}

void DefaultParameterContainer::setScreenResolution(int resol)throw(InvalidScreenResolutionException){
	if(resol==640){
		this->screenWidth = 640;
		this->screenHeight = 480;
	}
	else if(resol==800){
		this->screenWidth = 800;
		this->screenHeight = 600;
	}
	else if(resol==1024){
		this->screenWidth = 1024;
		this->screenHeight = 768;
	}
	else if(resol == 1280){
		this->screenWidth = 1280;
		this->screenHeight = 768;
	}
	else{
		throw InvalidScreenResolutionException("La resolucion de pantalla ingresada es Invalida");
	}
}

void DefaultParameterContainer::setScreenColor(Color* screenColor){
	DefaultParameterContainer::screenColor=screenColor;
}

Texture* DefaultParameterContainer::getTexture(){
	return DefaultParameterContainer::texture;
}

void DefaultParameterContainer::setTexture(Texture* texture){
	DefaultParameterContainer::texture = texture;
}

void DefaultParameterContainer::setFigureColor(Color* figureColor){
	DefaultParameterContainer::figureColor = figureColor;
}

int DefaultParameterContainer::getScreenHeight()const {
	if(DefaultParameterContainer::screenHeight!=NULL)
		return DefaultParameterContainer::screenHeight;
	else return DefaultParameterContainer::defaultScreenHeight;
}

int DefaultParameterContainer::getScreenWidth()const {
	if(DefaultParameterContainer::screenWidth!=NULL)
		return DefaultParameterContainer::screenWidth;
	else return DefaultParameterContainer::defaultScreenWidth;
}

Color* DefaultParameterContainer::getScreenColor(){
	if(this->screenColor!=NULL)
		return DefaultParameterContainer::screenColor;
	else return DefaultParameterContainer::defaultScreenColor;
}

Color* DefaultParameterContainer::getLineColor(){
	if(this->lineColor!=NULL)
		return DefaultParameterContainer::lineColor;
	else
		return DefaultParameterContainer::defaultLineColor;
}

Color* DefaultParameterContainer::getFigureColor(){
	if(DefaultParameterContainer::figureColor!=NULL)
		return DefaultParameterContainer::figureColor;
	else return DefaultParameterContainer::defaultFigureColor;
}

void DefaultParameterContainer::setLineColor(Color* lineColor){
	this->lineColor=lineColor;
}